package com.xwaf.platform.system.api.entity.mqtt;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;

import com.xwaf.platform.system.api.entity.DataBase;
import com.xwaf.platform.system.api.enums.MqttMessageStatus;

import lombok.Data;

/**
 * 
 * <p>
 * MQTT成功结构
 * <p>
 * 
 * @author 李聪 <br>
 * @email xwaf_love@yeah.net <br>
 * @since JDK 1.8<br>
 * @date 2019年12月27日 下午8:11:55 <br>
 * @see 无<br>
 *      Copyright (c) 2019, xwaf_love@yeah.net All Rights Reserved.<br>
 */
public class IMSuccessMessage extends IMMessage<IMSuccessMessage.Success> {

	private static final long serialVersionUID = 1L;

	private static MqttMessageStatus type = MqttMessageStatus.TEST;

	/**
	 * 成功消息构造
	 * 
	 * @return
	 */
	public static IMSuccessMessage newBulider(IMUser bidUser, String msg) {
		return newBulider(bidUser, msg, DataBase.getDataBaseId(DataBase.MQTT));
	}

	/**
	 * 成功消息构造
	 * 
	 * @return
	 */
	public static IMSuccessMessage newBulider(IMUser bidUser, String msg, String invokeId) {
		IMSuccessMessage.Success data = new IMSuccessMessage.Success();
		data.setBidUser(bidUser);
		data.setMsg(msg);
		IMSuccessMessage message = new IMSuccessMessage();
		message.setData(data);
		message.setType(type);
		message.setMessageId(StringUtils.isEmpty(invokeId) ? DataBase.getDataBaseId(DataBase.MQTT) : invokeId);
		return message;
	}

	@Data
	public static class Success implements Serializable {
		private static final long serialVersionUID = 1L;
		private IMUser bidUser;
		private String msg;
	}
}
